home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / tpa2_a.arc / TP&ASM.DOC < prev    next >
Text File  |  1991-04-28  |  21KB  |  531 lines

  1.  
  2.   TP&Asm           Integrated Compile-Time Assembler          Version 2 ß
  3.   TP&Asm-M   Memory Mode Assembly Language Development Tool   Version 2 ß
  4.  
  5.                 Copyright (c) 1989  Richard W. Prescott
  6.                           All Rights Reserved
  7.  
  8. ═══════ Built-In Assembly Language Support for Turbo Pascal Compilers ═══════
  9.  
  10.  All brand and product names mentioned herein are trademarks or registered 
  11.                 trademarks of their respective holders.
  12.  
  13.   ┌─────────────────────────────────────────────────────────────────────┐
  14.   │  This file contains information of a general nature, including      │
  15.   │  getting started quickly, and purchasing TP&Asm.  For detailed      │
  16.   │  reference information to enable you to make most effective use of  │
  17.   │  the TP&Asm assembly environment, please see the archive TPA2-R     │
  18.   │  (available 2/21/89).                                               │
  19.   └─────────────────────────────────────────────────────────────────────┘
  20.  
  21.  
  22. The following topics are described below:
  23.  
  24. 1. Overview
  25. 2. Features
  26. 3. System Requirements
  27. 4. Getting Started
  28. 5. Comparison of Methods
  29. 6. Quality Control
  30. 7. DISCLAIMER
  31. 8. TP&Asm vs TP&Asm-M
  32. 9. Purchase Information
  33.  
  34.  
  35.  
  36. Note:
  37.  
  38. TP&Asm-M refers to the sharable program file TPAM.EXE included in 
  39. this archive.  TP&Asm refers to the program file TPA.EXE which is 
  40. not included in this archive but which may be purchased, if desired, 
  41. as described in section 9.  All references in sections 1 through 5
  42. apply to both TP&Asm and TP&Asm-M.  See section 8 for further 
  43. details.
  44.  
  45.  
  46.  
  47. 1. Overview
  48.  
  49. TP&Asm and TP&Asm-M are integrated assemblers for Turbo Pascal 
  50. versions 4.0 and 5.0 which operate during the compile step to 
  51. provide support for the four TP&Asm keywords "Assemble" (or 
  52. "Assembly"), "Internal", "CsData", and "Asm":
  53.  
  54.       Assemble                       Internal <DataName>
  55.         ∙                              ∙
  56.         (Assembly                      (Assembly
  57.          Instructions)                  Instructions)
  58.         ∙                              ∙
  59.       End;                           End;
  60.  
  61.       CsData
  62.         ∙
  63.         (Db, Dw, or Dd
  64.          Statements)
  65.         ∙
  66.       End;
  67.  
  68.       Asm <Assembly Statement>;
  69.  
  70.  
  71. Briefly:
  72.  
  73.   "Assemble" defines a block of standard 8086 assembly language
  74.     statements which can be placed wherever an Inline statement 
  75.     would be valid (including 'Inline Directives').  
  76.  
  77.   "Internal" provides support for assembly language code originally 
  78.     designed for an external assembler.  
  79.  
  80.   "CsData" defines a block of initialized or uninitialized data
  81.     which is allocated in the current Code segment and is 
  82.     accessable throughout the current Unit (used primarily with
  83.     customized interrupt procedures and resident applications). 
  84.  
  85.   "Asm" provides a concise way of specifying single-line assembly
  86.     sections.
  87.  
  88.  
  89. As of Version 2, the following compilers are supported:
  90.  
  91.       TURBO.EXE    Version 4.0 and Version 5.0
  92.       TPC.EXE      Version 4.0 and Version 5.0
  93.  
  94.  
  95. Example:
  96.  
  97. The following simple function compiles successfully when a 
  98. supported compiler is run under TP&Asm: 
  99.  
  100.       FUNCTION DosMajorVersion: BYTE;
  101.       BEGIN
  102.         Assembly
  103.           Mov Ah,30h ;or use $30 or 030 to indicate hex
  104.           Int 21h
  105.           Mov DosMajorVersion,Al ;put in function result
  106.         END; {Assembly}
  107.       END; {FUNCTION DosMajorVersion}
  108.        ∙
  109.        ∙
  110.       IF DosMajorVersion >= 3 
  111.       THEN { get program name from "environment" ... }
  112.  
  113.  
  114.  
  115. 2. Features of TP&Asm/TP&Asm-M
  116.  
  117.  ■ Runs Turbo/TPC as a subprocess.  Simple to use, yet powerful 
  118.    enough to run ANY command line under TP&Asm.  For example, 
  119.    "tpam Command" can be used to make TP&Asm-M "Memory resident".
  120.    See the archive TPA2-R (available 2/21/89).
  121.  
  122.  ■ Compact: Program size 43K, TOTAL Memory usage less than 55K 
  123.    (Frees its own "environment" block for reuse by the subprocess) 
  124.  
  125.    - yet -
  126.  
  127.  ■ Imposes NO limits on Source Code size, Object Code size, or Data 
  128.    Seg symbols.  (Your program must still satisfy any Compiler 
  129.    limits, however) 
  130.  
  131.  ■ Fast Assembly from Memory - TP&Asm imposes NO additional disk 
  132.    access time, even for Include files.  
  133.  
  134.  ■ Fully compatible with the Turbo 5.0 integrated debugger.  The
  135.    Unit ASMWATCH (included) allows you to Watch, Evaluate, and
  136.    Modify the state of all CPU registers and flags.
  137.  
  138.  ■ Fully integrated with the Turbo built-in Linker.  Permits direct
  139.    Call, Jmp, and Offset references to Pascal Proc/Functions.
  140.    (These references are recognized by the Turbo Smart Linker).
  141.  
  142.    - yet -
  143.  
  144.  ■ Units compiled with TP&Asm may be Used in Pascal programs compiled
  145.    without TP&Asm.
  146.  
  147.  ■ Freely mix Pascal and assembly sections.  Pascal Labels placed
  148.    in assembly sections can be the target of any GOTO statement.
  149.    Assembly statements can branch to (Jmp, Loop, jNZ, etc) or Call
  150.    any Pascal or assembly label.
  151.  
  152.  ■ Performs automatic Jump-Sizing for all backward AND FORWARD
  153.    Jumps and Loops.  Always builds smallest possible instruction
  154.    (does not pad code with NOPs).
  155.  
  156.  ■ Supports all 8086 Assembly mnemonics and all assembler directives 
  157.    that make sense within a Turbo Pascal program.  
  158.  
  159.  ■ Supports numerous extensions for compatibility with Eric 
  160.    Isaacson's A86 Assembler (Multiple operands to Push, IF's, Local 
  161.    Labels, etc).
  162.  
  163.  ■ Recognizes all common decimal and hexidecimal numeric formats, 
  164.    including leading '$' for compatibility with Dave Baldwin's 
  165.    INLINE.COM.  
  166.  
  167.  ■ Automatically supplies correct segment override and base register 
  168.    needed to reference most Pascal and Assembly variables.  (This 
  169.    feature may be disabled for "WYSIWYG" assembly).  
  170.  
  171.  ■ Allows setting function results by name, e.g.: 
  172.    "Mov FunctionName,TRUE" (Automatically recognizes Built-In 
  173.    compiler symbols such as TRUE).  
  174.  
  175.  ■ Provides extensive syntax error checking, completely integrated 
  176.    with the compiler's syntax checking.  The cursor is placed at the 
  177.    point in your assembly language code where the error occurred.  
  178.  
  179.  ■ Supports Warning level errors, with option to Ignore or Halt on 
  180.    warnings.  
  181.  
  182.  ■ Does not disable "Inline" or "External" - these keywords are 
  183.    still available, but are no longer necessary.  Any or all of
  184.    the keywords Assemble, Internal, External, and Inline may be
  185.    used in each program or unit.
  186.  
  187.  
  188.  
  189. 3. System Requirements
  190.  
  191. TP&Asm and TP&Asm-M Version 2 ß require: the IBM PC version of Turbo
  192. Pascal 4.0 or 5.0 running on an IBM PC or Compatible, with Version
  193. 2.0 or above of MS-DOS or PC-DOS.  Minimum memory requirements are
  194. 55K more than the memory required by the compiler.  
  195.   
  196.  
  197.  
  198. 4. Getting Started
  199.  
  200. This archive contains the full working version of the TP&Asm-M
  201. Memory Mode Assembly Language Development Tool.  If you have a 
  202. supported compiler, simply type 'tpam' in place of 'turbo' at the 
  203. system prompt.  TPAM will automatically find and run turbo.exe, 
  204. using the same search sequence as DOS.  (See the archive TPA2-R, 
  205. available 2/21/89, for other command line options when starting 
  206. TP&Asm).  
  207.  
  208. Now read in some of the test files.  Browse through them to see 
  209. what they do, then compile and run them.  Modify them and run again.  
  210. Turbo Version 5 users, set up the watch expressions as indicated in 
  211. the file DEMONEW.PAS and observe the CPU registers and flags as you 
  212. single-step through the assembly code.  Observe how easy it is to 
  213. experiment with assembly language in your programs.  Observe the 
  214. response to syntax errors.  TP&Asm does not intrude into your 
  215. programming environment - you are running Turbo Pascal, and the 
  216. assembler is integrated so smoothly into the system that you may 
  217. forget you are using it.  It is active, however, every time the 
  218. compiler calls upon it to translate an Assemble or Internal 
  219. statement.  
  220.  
  221.  
  222.  
  223. 5. A Comparison of (Assembly Language) Methods
  224.  
  225. This section discusses advantages and disadvantages of the four 
  226. basic methods of using machine code/assembly language within a Turbo 
  227. Pascal program:  Inline and External (as provided by Turbo Pascal),
  228. and Internal and Assemble (provided by TP&Asm).  (Skip this section 
  229. if you're already convinced).  
  230.  
  231. INLINE:
  232.  
  233. The disadvantage of the Inline statement is obvious - no support for 
  234. mnemonics.  Every instruction must be assembled by hand, jumps and 
  235. loops are essentially impossible, etc.  Direct calls to Pascal
  236. Procedures and Functions are not permitted.
  237.  
  238. An advantage, however, is that code may be placed anywhere in the 
  239. code stream, not just into separate callable Proc/Functions, and 
  240. Turbo identifiers may be referenced by name.  In addition, Inline 
  241. statements may be used to define machine code MACROs.  
  242.  
  243. EXTERNAL:
  244.  
  245. The advantage of External is, just as obviously, full support of 
  246. assembly mnemonics (or whatever subset is supported by your external 
  247. assembler).  May also permit access to the symbol "SEG DATA" for 
  248. restoring the program Data Segment (useful in interrupt routines).
  249.  
  250. Disadvantages of External are:
  251.  
  252.   Code must always go into separate callable Global Proc/Functions.
  253.  
  254.   Limited support for Global Pascal identifier references.
  255.    Referenced identifiers must be declared in EXTRN statements.  
  256.  
  257.   Limited "dead code removal" - Turbo Pascal links in External .OBJ 
  258.    modules in an "all or nothing" fashion.
  259.  
  260.   All references to Proc/Function parameters and Function results 
  261.    returned on the stack must be coded explicitly (not referenced 
  262.    by name) and may need to be changed for future versions of the 
  263.    compiler.  Note however that Borland's TASM provides the 
  264.    ".MODEL TPASCAL" directive which permits the same simplified
  265.    parameter references as the TP&Asm Assemble statement.
  266.  
  267.  
  268. INTERNAL:
  269.  
  270. Internal is essentially a direct replacement for External,
  271. supporting 8086 Assembly mnemonics and access to the symbol
  272. "SEG DATA".
  273.  
  274. Improvements:
  275.  
  276.   Full support for Global Pascal variable references with no need 
  277.    for EXTRN.
  278.  
  279.   Full "dead code removal" on a Proc by Proc basis within each
  280.    INTERNAL statement.  Permits development of efficient libraries
  281.    of assembly routines compiled into standard 4.0 or 5.0 TPUs.
  282.  
  283. Not Improved:
  284.  
  285.   Code still must go into separate callable Global procs.
  286.  
  287.   Parameter and function results must still be explicitly coded.
  288.  
  289.  
  290. ASSEMBLE:
  291.  
  292. Advantages:
  293.  
  294.   As with External, supports 8086 Assembly mnemonics and access to
  295.    the symbol "SEG DATA" (8087 mnemonics are not yet supported).
  296.  
  297.   As with Inline, code may be placed anywhere in the code stream, 
  298.    INCLUDING in the definition of (assembly) Inline Directive/MACROs 
  299.  
  300.   As with Internal, provides full support for global Pascal variable
  301.    references without EXTRN, and permits direct Call (or Jmp) to any
  302.    Pascal or Internal Proc/Function.
  303.  
  304.   In fact, all Pascal variables/parameters which are global or local 
  305.    to the current Proc/Function may be referenced by the standard 
  306.    Pascal name (without '[BP]', 'CS', etc.).  Function results may 
  307.    likewise be put in by name.  There is no need to be concerned 
  308.    with the details of Stack usage and parameter passing for any
  309.    particular compiler.
  310.  
  311.   Provides capability of allocating and referencing NAMED 
  312.    initialized (or uninitialized) data in the current code seg.
  313.  
  314.  
  315. To summarize,
  316.  
  317.  In terms of coding convenience:
  318.     ■ External is a major improvement over Inline
  319.     ■ Internal is a moderate improvement over External
  320.     ■ Assemble is a major improvement over Internal and External
  321.  
  322.  In terms of flexibility of use:
  323.     ■ Assemble and Inline have advantages over External and Internal
  324.  
  325.  
  326. It should be clear at this point that the Assemble statment provides 
  327. the most versatile and convenient means of including assembly 
  328. language in your programs.  Now consider the fact that with Assemble 
  329. (and Internal) you don't need to leave the compiler at any point 
  330. during your program development, and you can see that TP&Asm offers 
  331. you an immense improvement in program development speed.  The time 
  332. consuming assembly development loop of:
  333. Exit Turbo/ Assemble/ Reenter Turbo/ Compile &/or Link/ Test/ Repeat
  334. is replaced by the simple and familiar  Edit/Run/Repeat  loop.
  335. With TP&Asm you can be wrapped up & on your way home while others 
  336. are still watching their assemblers clean up temporary disk files.  
  337.  
  338.  
  339. Even if your primary goal is to write stand-alone assembly programs,
  340. consider the advantage of using Turbo/TP&Asm as a program 
  341. development environment.  You can develop, test and debug your 
  342. assembly routines using all the power and flexibility of Pascal in 
  343. the testing process - then port your code unchanged** to A86 or 
  344. your favorite stand-alone assembler.  See, for example, HEXBYTE.PAS.
  345.  
  346. ** regarding compatability:  essentially, it is a simple matter to 
  347.    design your code so that it requires NO changes in porting from 
  348.    TP&Asm to A86, MASM, TASM, or any assembler that is reasonably 
  349.    compatible with one of these.  You must of course avoid using 
  350.    any TP&Asm enhancements that are not supported by your assembler.  
  351.  
  352.  
  353. The paragraphs above address the issue of why you should use 
  354. TP&Asm when you use assembly language ... but why use assembly 
  355. language at all?
  356.  
  357. The two principal reasons for using assembly language in a Pascal 
  358. program are: 
  359.    1) To do something that cannot be done in Pascal 
  360.       (MICROMTR.PAS; also see the archive TP-TSR)
  361.    2) To do something much faster than it can be done in Pascal
  362.       (FIND.PAS, COMPARE.PAS)
  363. A third reason, to minimize code size, has become less important 
  364. with the advent of cheap memory chips and hard disks.  One would 
  365. seldom want to go to the trouble of recoding a major application 
  366. in assembly language simply to save code size.  (An exception is
  367. the "memory resident" type program, where mimimum code size is 
  368. usually very important).
  369.  
  370.  
  371.  
  372. 6. Quality Control
  373.  
  374. This program has been tested by assembling over 6000 variations of 
  375. assembly language statements and running the Turbo/TP&Asm output 
  376. Exe file through EXAMINE.EXE to produce a "side by side" display 
  377. of each assembly source statement together with its corresponding 
  378. DEBUG.COM disassembly.  All modifications are retested against the 
  379. same test files.  EXAMINE.EXE is provided free of charge on the 
  380. TP&Asm distribution disk so that users may easily verify proper 
  381. assembly within their own programs.  It can also be found in the
  382. archive TP-XMN, available 2/28/89.  (EXAMINE requires a compiled 
  383. EXE and MAP file and a copy of DEBUG.COM).
  384.  
  385.  
  386. TP&Asm, TP&Asm-M, and Examine are all compiled and assembled using 
  387. TP&Asm Version 2 ß running Turbo Pascal Version 5.0.
  388.  
  389.  
  390.  
  391. 7. DISCLAIMER OF WARRANTY
  392.  
  393. This software and accompanying documentation are sold "as is" and 
  394. without warranties as to performance or merchantability.
  395.  
  396. This program is sold without any express or implied warranties 
  397. whatsoever.  Because of the diversity of conditions and hardware 
  398. under which this program may be used, no warranty of fitness for a 
  399. particular purpose is offered.  The user is advised to test the 
  400. program thoroughly before relying on it.  THE USER MUST ASSUME THE 
  401. ENTIRE RISK OF USING THE PROGRAM.  ANY LIABILITY OF THE AUTHOR WILL 
  402. BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF THE 
  403. PURCHASE PRICE.  
  404.  
  405.  
  406.  
  407. 8. TP&Asm vs TP&Asm-M 
  408.  
  409. "TP&Asm" refers to the Integrated Compile-Time Assembler package 
  410. containing the program file TPA.EXE.  TPA supports Compile to Disk 
  411. as well as Assemble/Compile and Run within the Turbo environment.  
  412.  
  413. "TP&Asm-M" refers to the sharable Memory Mode Assembly Language 
  414. Development package which contains the program file TPAM.EXE, but 
  415. does not contain TPA.EXE.  TPAM provides the same assembly language 
  416. capabilities as TPA, but is intended only for assembly language 
  417. development within the Turbo 4.0 or 5.0 integrated environments,
  418. and therefore does not have the capability of compiling to disk.  
  419. (You can of course read and save Pascal and Assembly SOURCE files 
  420. with both programs).  
  421.  
  422. The TP&Asm-M package is sharable, however the TP&Asm package is not.  
  423.  
  424.  
  425. Why not distribute both TP&Asm and TP&Asm-M as shareware?  
  426.  
  427. I have given a great deal of thought to this.  I did not wish to 
  428. annoy potential users by creating a limited demo version which 
  429. provides no useful function.  At the same time, however, I feel 
  430. strongly that a shareware user who registers a program would 
  431. appreciate receiving some sort of genuine "bonus" beyond a printed 
  432. copy of the documentation file.  I have attempted to resolve this 
  433. conflict by creating what I believe to be a useful program (TP&Asm-M) 
  434. which is fully sharable and which demonstrates ALL the features 
  435. of an even more useful program (TP&Asm).  Users may register for 
  436. TP&Asm and receive a genuine bonus, or register for TP&Asm-M only, 
  437. at a considerable discount.  
  438.  
  439. The usefulness that I attribute to TP&Asm-M is in the opportunity to 
  440. dramatically reduce development time for your External and Inline 
  441. assembly language routines.  TP&Asm-M permits you to get the heart 
  442. of any assembly routine working in a friendly environment that does 
  443. not require a series of "assembler overhead" directives and 
  444. complicated stack offset parameter references.  Once the routine is 
  445. working, you can add in the overhead directives and parameter 
  446. offsets, and run the resulting code through your external assembler, 
  447. secure in the knowledge than any remaining problems would be due 
  448. only to possible incorrect parameter offsets and not to any flaw in 
  449. the logic of the assembly routine itself.  
  450.  
  451. TP&Asm-M is also convenient for users who simply want to learn about 
  452. and experiment with 8086 assembly language.  With TP&Asm-M and Turbo 
  453. Version 5.0 you can single step your experimental code and instantly 
  454. view the effects on CPU registers, flags, stack contents, and Pascal 
  455. variables in the compiler's Watch window.  
  456.  
  457. Although I firmly believe that TP&Asm-M is a full featured, useful 
  458. program, and although it is fully sharable, I have chosen to not 
  459. refer to it as "shareware".  This is out of consideration for the 
  460. definition used by the Association of Shareware Professionals, who 
  461. firmly believe that shareware packages should not be limited in any 
  462. way, and who might obviously argue that TP&Asm-M, while useful in 
  463. its own right, is still a limited version of TP&Asm.  
  464.  
  465.  
  466.  
  467.  
  468. 9. Purchase Information.
  469.  
  470. After you have reviewed the TP&Asm-M package for a reasonable period 
  471. of time (say, 30 days), please register it or purchase TP&Asm if you 
  472. plan to continue using it.  Even if you choose not to register, I
  473. encourage you to retain a copy of TP&Asm-M and distribute it to 
  474. others via BBS or on diskette.  Please include all files in both the 
  475. program and reference archives (TPA2-A and TPA2-R). 
  476.  
  477. If you find that this software does not perform as described, please 
  478. let me know.  I am proud of this program and I want it to work right 
  479. for you.  If you are dissatisfied, I will refund your purchase price.
  480. I only ask that you clearly state the manner in which it failed to 
  481. perform as described when you return the distribution disk (and, of 
  482. course, that you discontinue using the program).  I will accept your 
  483. judgement without argument.  Consider the spirit in which this offer 
  484. is made, and please be fair.
  485.  
  486. The current version 2 ß is the final beta test stage for TP&Asm 
  487. Release 2.0.  As indicated below, users who purchase the current 
  488. beta test version and thereby assist me in final verification 
  489. receive a $10 discount and a free update when Version 2.0 is 
  490. released.
  491.  
  492.  
  493. Trial and Update Disks ...  $5 + $3 P&H
  494.  
  495. TP&Asm-M Registration  ... $19 + $3 P&H for registration + disk
  496.                            $19  (total) for registration only
  497.  
  498. TP&Asm Version 2.0     ... $49 + $3 P&H (not yet available)
  499.  
  500. TP&Asm Version 2 ß     ... $39 + $3 P&H including free upgrade
  501.                                           to Version 2.0.
  502.  
  503. (Wisconsin residents, please add 5% sales tax).
  504.  
  505. All prices listed are for standard 5 1/4 inch floppy disks.  Add
  506. $2 for distribution on 3 1/2 inch disks.
  507.  
  508.  
  509. If you originally purchased a Trial Disk you may deduct $5 from the 
  510. above prices when registering TP&Asm-M or purchasing TP&Asm.  
  511.  
  512.  
  513. Please send a check or money order payable to:
  514.  
  515.                       Richard W. Prescott
  516.                       724 Sauk Ridge Trail
  517.                       Madison, WI  53705
  518.  
  519. Please include the following information:
  520.  
  521.   1. Full Version number of the Turbo Pascal compiler you now use.
  522.  
  523.   2. Your registration number for that compiler.
  524.  
  525.   3. If you obtained TP&Asm-M from a bulletin board:
  526.      3a. Area code and phone number of that bulletin board
  527.      3b. Full Version number of the TP&Asm-M version you have
  528.      3c. Directory Date of the README file
  529.  
  530.  
  531.